#include "EventManager.h"


EventManager * EventManager::selfSingleton = NULL;
EventManager::EventManager()
{
	eventID = 0;
}
EventManager::~EventManager()
{

}
EventManager* EventManager::getInstance()
{
	if(EventManager::selfSingleton == NULL)
	{
		EventManager::selfSingleton = new EventManager();
	}
	return EventManager::selfSingleton;
}

void EventManager::TriggerEvent(int eventType, void * Sender, void * Event, int time)
{
	std::pair< int,EventWrapper *> _tmp;
	EventWrapper* _e = new EventWrapper();
	_tmp.second = _e;
	_e->Event = Event;
	_e->eventID = eventID++;
	_e->eventType = eventType;
	_e->Sender = Sender;
	_tmp.first = _e->eventID;
	
	mEventMap.insert(_tmp);
}

void EventManager::EventExecuteUpdate()
{
	std::map<int,EventWrapper *>::iterator eit = mEventMap.begin();
	while(eit != mEventMap.end())
	{
		EventWrapper *_event = eit->second;

		mEventMap.erase(eit);	
		eit = mEventMap.begin();

		switch(_event->eventType)
		{
		case 1:
			{
				
			}
			break;
		default:
			break;
		}
	}
}